<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>我的收藏</title>
  <meta name="renderer" content="webkit"/>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    {foreach name="list" item="v"}
        <div>
            <a href="{:url('GoodsList/goods_detail')}?id={$v.id}">
                <img src="{$v.logo}" width="100px;" height="100px;">
                <p>{$v.name}&nbsp;&nbsp;{$v.price}</p>
                <p>{$v.name}&nbsp;&nbsp;{$v.price}</p>
            </a>
            <a href="javascript:;" onclick="cancel_collect(this,{$v.id})">取消收藏</a>
        </div>
    {/foreach}
</body>
</html>
<script>
    /**
     * 取消收藏
     */
    function cancel_collect(obj,id){
        $.post("{:url('User/cancel_collect')}",
            {id:id},
            function(data){
                if(data.code == 1){
                    alert('取消成功');
                    $(obj).parent().remove();
                }else{
                    alert('取消失败');
                }
            }
        );
    }
</script>